package com.aabte.springbootlearn.springbootprometheus;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author Daniel
 */
@Configuration
public class MVCInterceptorConfig extends WebMvcConfigurationSupport {

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {

        RequestCounterInterceptor requestCounterInterceptor = new RequestCounterInterceptor();
        registry.addInterceptor(requestCounterInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/prometheus");

        RequestTimingInterceptor requestTimingInterceptor = new RequestTimingInterceptor();
        registry.addInterceptor(requestTimingInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/prometheus");

        super.addInterceptors(registry);
    }
}
